package com.spring.web.adminmanage.service.impl;

import com.spring.web.adminmanage.entities.User;
import com.spring.web.adminmanage.repository.WebUserDao;
import com.spring.web.adminmanage.service.LoginService;
import com.spring.web.adminmanage.utils.SwordBCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
	
	@Autowired
	private WebUserDao userdao;

	@Override
	public boolean cookieVerification(String uid, String sid,String remoteAddr) {
		User user = new User();
		user.setUsername(uid);
		user = userdao.selectOne(user);
		if (user==null) {
			return false;
		}
		return SwordBCrypt.checkpw(uid+user.getSysPwd()+remoteAddr, sid);
	}
}
